#include <mockcpp/mockcpp.hpp>
#include <testngpp/testngpp.hpp>

#include <LengthUnit.h>
#include <VolumeUnit.h>
#include <Measurement.h>
#include <string>
#include <PrintFormat.h>
using namespace std;

USING_MOCKCPP_NS
USING_TESTNGPP_NS

FIXTURE(Measurement)
{
    TEST( 1 Mile equals 1760 Yard )
    {       
      ASSERT_EQ( Measurement(1, MILE), Measurement(1760, YARD) );
    }

    TEST( 1 Yard equals 3 Feet )
    {
      ASSERT_EQ( Measurement(1, YARD), Measurement(3, FEET) );
    }

    TEST( 1 Oz equals 3 Tsp)
    {
      ASSERT_EQ( Measurement(1, OZ), Measurement(3, TSP) );
    }

    TEST( 1 Tsp equals 4 Tbsp )
    {
      ASSERT_EQ( Measurement(1, TSP), Measurement(4, TBSP) );
    }

    TEST( 1 Mile does not equal 1 Oz )
    {
      ASSERT_NE( Measurement(1, MILE), Measurement(1, OZ) );
    }

    TEST(1 Mile plus 1760 Yards equals 2 Miles)
    {
      ASSERT_EQ( (Measurement(1, MILE) + Measurement(1760, YARD)),  Measurement(2, MILE) );
    }

    TEST(1 OZ plus 3 tsp equals 2 OZ)
    {
      ASSERT_EQ( (Measurement(1, OZ) + Measurement(3, TSP)),  Measurement(2, OZ) );
    }
    
    TEST(1 Mile plus 1760 Yards does not equal 3 Miles)
    {
      ASSERT_NE( (Measurement(1, MILE) + Measurement(1760, YARD)),  Measurement(3, MILE) );
    }

    TEST(1 Mile plus 1760 Tbsp does not equal 3 Miles)
    {
      ASSERT_NE( (Measurement(1, MILE) + Measurement(1760, TBSP)),  Measurement(3, MILE) );
    }
};

FIXTURE(Measurement_Printing_FormatToBigUnit)
{
    TEST(Format 1780 Yard to 1 Mile and 20 Yard)
    {
      string outstring("1 Mile 20 Yard");
      Measurement  yard1780(1780, YARD);
      ASSERT_EQ(yard1780.getAndPrint(Format_Big), outstring); 
    }

    TEST(Format 8000 Feet to 1 Mile and 906 Yard and 2 Feet)
    {
      string outstring("1 Mile 906 Yard 2 Feet");
      Measurement  feet8000(8000, FEET);
      ASSERT_EQ(feet8000.getAndPrint(Format_Big), outstring);       
    }

    TEST(Format 5280 Feet to 1 Mile)
    {
      string outstring("1 Mile");
      Measurement  feet5280(5280, FEET);
      ASSERT_EQ(feet5280.getAndPrint(Format_Big), outstring);       
    }

    TEST(Format 5282 Feet to 1 Mile and 2 Feet)
    {
      string outstring("1 Mile 2 Feet");
      Measurement  feet5282(5282, FEET);
      ASSERT_EQ(feet5282.getAndPrint(Format_Big), outstring);       
    }

    TEST(Format 1000 Mile to 1000 Mile)
    {
      string outstring("1000 Mile");
      Measurement  mile1000(1000, MILE);
      ASSERT_EQ(mile1000.getAndPrint(Format_Big), outstring); 
    }

    TEST(Format 0 Mile to 0 Feet)
    {
      string outstring("0 Feet");
      Measurement  mile0(0, MILE);
      ASSERT_EQ(mile0.getAndPrint(Format_Big), outstring);
    }

};


FIXTURE(Measurement_Printing_FormatToSmallUnit)
{
    TEST(Format 1780 Yard to 5340 Feet)
    {
      string outstring("5340 Feet");
      Measurement  yard1780(1780, YARD);
      ASSERT_EQ(yard1780.getAndPrint(Format_Small), outstring); 
    }

    TEST(Format 1000 Mile to 5280000 Feet)
    {
      string outstring("5280000 Feet");
      Measurement  mile1000(1000, MILE);
      ASSERT_EQ(mile1000.getAndPrint(Format_Small), outstring); 
    }

    TEST(Format 0 Mile to 0 Feet)
    {
      string outstring("0 Feet");
      Measurement  mile0(0, MILE);
      ASSERT_EQ(mile0.getAndPrint(Format_Small), outstring); 
    }

};



